<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>物资出库</title>
    <link rel="stylesheet" href="/css/elementui/index.css">
    <link rel="stylesheet" href="/css/exam/css/style.css">
    <link rel="stylesheet" href="/iconfont/iconfont.css">
    <script src="/css/exam/js/httpVueLoader.js"></script>
</head>

<body>
    <div id="app">
        <!--导航切换-->
        <div class=".p-30">
            {{ csrf_field() }}
            <el-card>
                <el-form label-width="100px" :model="formInline" :rules="rules" ref="increase">
                    <!-- <el-card> -->
                    <el-row>
                        <p>出库清单添加</p>
                    </el-row>
                    <el-row type="flex">

                        <el-form-item label="出库类型" prop="outbound_type">
                            <el-select v-model="formInline.outbound_type" placeholder="请选择出库类型" style="width:150px">
                                <el-option v-for="(item, index) in options" :key="index" :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>

                        </el-form-item>

                        <el-form-item label="出库事由" prop="incident">
                            <el-input v-model="formInline.incident" style="width:150px" placeholder="请输入出库事由"></el-input>
                        </el-form-item>

                        <el-form-item label="申请人" prop="applicant">
                            <el-input v-model="formInline.applicant" style="width:150px" placeholder="请输入申请人"></el-input>
                        </el-form-item>

                        <el-form-item label-width="50px">
                            <el-button type="primary" @click='add_details'>添加明细</el-button>
                        </el-form-item>

                    </el-row>

                </el-form>
            </el-card>
            <!-- 弹窗 -->
            <el-dialog title="物资详情" :visible.sync="dialogVisible" width="90%">
                <el-form :model="equipment_tools" ref="verification" label-width="10px">
                    <el-row type="flex">

                        <el-form-item prop="classification_name">
                            <!-- <el-select v-model="equipment_tools.classification_name" placeholder="请选择分类名称"
                                style="width:180px" @change="ChangeGoods">
                                <el-option v-for="(item, index) in goodsdata" :key="item.id" :label="item.name"
                                    :value="item.id">
                                </el-option>
                            </el-select> -->


                              <el-cascader
                              v-model="equipment_tools.classification_name"
                              placeholder="请选择分类名称"
                             :options="goodsdata"
							 :props="{label:'name',value:'id'}"
                            >

                              </el-cascader>



                        </el-form-item>

                        <el-form-item prop="materials">

                            <!-- <el-select v-model="equipment_tools.materials" placeholder="请选择物资名称" style="width:180px"
                                filterable>
                                <el-option v-for="(item,key ,index) in materialList" :key="item.id" :label="item.name"
                                    :value="item.name">
                                </el-option>
                            </el-select> -->


                              <el-input v-model="equipment_tools.materials" style="width:150px" placeholder="请输入物资名称"></el-input>

      

                        </el-form-item>
                        <el-form-item prop="unit">
                            <el-select v-model="equipment_tools.unit" placeholder="请选择所属单位" style="width:180px"
                                @change="ChangeHandler">
                                <el-option v-for="item in checkcategory" :key="item.id" :label="item.name"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item prop="classify">
                            <el-select v-model="equipment_tools.classify" placeholder="请选择单位名称" style="width:180px"
                                filterable>
                                <el-option v-for="item in companys" :key="item.id" :label="item.comName"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" @click="primary">搜&ensp;&ensp;索</el-button>
                            <el-button @click="resetForm('verification')">重&ensp;&ensp;置</el-button>
                        </el-form-item>
                    </el-row>
                </el-form>
                <el-table border='' :data="information" style="width: 100%" @selection-change="handleSelectionChange">
                    <el-table-column type="selection" width="72" :selectable='selectEnable'>
                    </el-table-column>
                    <el-table-column label="序&ensp;&ensp;号" width="80" type='index' align='center'>
                    </el-table-column>
                    <el-table-column label="单位（个人）名称" prop="company.comName" width='150' align='center'>
                    </el-table-column>
                    <el-table-column label="所属单位（人）" prop="checkcategory.name" width="150" align='center'>
                    </el-table-column>
                    <el-table-column label="物资名称" prop="material_list.name" width="" align='center'>
                    </el-table-column>
                    <el-table-column label="物资分类" prop="goods.name" width="" align='center'>
                    </el-table-column>
                    <el-table-column label="具体位置" prop="company.address" width="" align='center'>
                    </el-table-column>
                    <el-table-column label="联系人" prop="company.leader" width="" align='center'>
                    </el-table-column>
                    <el-table-column label="联系电话" prop="company.leaderPhone" width="" align='center'>
                    </el-table-column>
                    <el-table-column label="库存数量" prop="warehouse" width="" align='center'>
                    </el-table-column>
                    <el-table-column label="单&ensp;&ensp;位" prop="unit" width="" align='center'>
                    </el-table-column>
                </el-table>
                <div>
                    <div style="text-align: center">
                        <el-row style="margin-top:30px">
                            <el-col>
                                <el-button type="primary" @click="btnok">确&ensp;&ensp;定</el-button>
                                <el-button @click="btnCancel">取&ensp;&ensp;消</el-button>
                            </el-col>
                        </el-row>
                    </div>
                </div>
            </el-dialog>
            <!-- 出库单添加 -->
            <div class="main" style="width: 100%; margin: 0 auto;">
                <div v-if="flag == 0">
                    <h3 style="text-align: center">北宅街道应急物资出库单</h3>
                    <el-form ref="formData" :model="formData">
                        <el-table style="width: 100%" border :data="formData.checkList">
                            <el-table-column label="类&ensp;&ensp;别" width="" align='center' prop="goods.name">
                            </el-table-column>
                            <el-table-column label="序&ensp;&ensp;号" type='index' width="80" align='center'>
                            </el-table-column>
                            <el-table-column label="物资名称" width="" align='center' prop="material_list.name">
                            </el-table-column>
                            <el-table-column label="库存" width="" align='center' prop="warehouse">
                            </el-table-column>
                            <el-table-column label="数&ensp;&ensp;量" width="" align='center' prop="number">
                                <template slot-scope="scope">
                                    <el-form-item :prop="'checkList.' + scope.$index + '.number'"
                                        :rules='rules1.number'>
                                        <el-input v-model.number='scope.row.number' type="number"
                                            @change='(v)=>changereqair(v,scope.row,scope.$index)'
                                            :max="scope.row.warehouse*1" :min=1></el-input>
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column label="单&ensp;&ensp;位" width="" align='center' prop="unit">
                            </el-table-column>
                            <el-table-column label="规&ensp;&ensp;格" width="" align='center' prop="norms">
                            </el-table-column>
                            <el-table-column label="所属单位" width="" align='center' prop="checkcategory.name">
                            </el-table-column>
                            <el-table-column label="单位名称" width="" align='center' prop="company.comName">
                            </el-table-column>
                            <el-table-column label="具体位置" width="" align='center' prop="company.address">
                            </el-table-column>
                            <el-table-column label="备&ensp;&ensp;注" width="" align='center' prop="">
                            </el-table-column>
                            <el-table-column label="操&ensp;&ensp;作" width="" align='center'>
                                <template slot-scope="scope">
                                    <el-button @click.native.prevent="deleteRow(scope.$index,formData.checkList)"
                                        type="text" size="small">
                                        删除
                                    </el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-form>
                    <div style="text-align: center">
                        <el-row style="margin: 20px 0">
                            <el-col>
                                <el-button type="primary" @click="submit">确&ensp;&ensp;定</el-button>
                                <el-button type="primary" @click="cancellation">取&ensp;&ensp;消</el-button>
                            </el-col>
                        </el-row>
                    </div>
                </div>
                <!-- 出库单修改 -->
                <div v-else>
                    <h3 style="text-align: center">北宅街道应急物资出库单</h3>
                    <el-form ref="formData" :model="formData" v-loading="loading">
                        <el-table style="width: 100%" border :data="editList">
                            <el-table-column label="类&ensp;&ensp;别" width="" align='center' prop="stock.goods.name">
                            </el-table-column>
                            <el-table-column label="序&ensp;&ensp;号" type='index' width="80" align='center'>
                            </el-table-column>
                            <el-table-column label="物资名称" width="" align='center' prop="stock.material_list.name">
                            </el-table-column>
                            <el-table-column label="库存" width="" align='center' prop="stock.warehouse">
                            </el-table-column>
                            <el-table-column label="数&ensp;&ensp;量" width="" align='center' prop="number">
                                <template slot-scope="scope">
                                    <el-input v-model.number='scope.row.number' type="number"
                                        @change='(v)=>changereqair1(v,scope.row,scope.$index)'
                                        :max="scope.row.warehouse*1" :min=1></el-input>
                                </template>
                            </el-table-column>
                            <el-table-column label="单&ensp;&ensp;位" width="" align='center' prop="stock.unit">
                            </el-table-column>
                            <el-table-column label="规&ensp;&ensp;格" width="" align='center' prop="stock.norms">
                            </el-table-column>
                            <el-table-column label="所属单位" width="" align='center' prop="stock.checkcategory.name">
                            </el-table-column>
                            <el-table-column label="单位名称" width="" align='center' prop="stock.company.comName">
                                <!-- <template slot-scope={row}>
                  <template v-if="row.warehouseOutbound.length">
                    <template v-for="(item,i) in row['warehouseOutbound']">
                    <span v-text="item.stock.company.comName"></span>
                      <el-divider 
                        v-if="i == row['warehouseOutbound'].length - 1 ? false : true"
                      ></el-divider>
                    </template>
                  </template>
                </template> -->
                            </el-table-column>
                            <el-table-column label="具体位置" width="" align='center' prop="stock.company.address">
                                <!-- <template slot-scope={row}>
                  <template v-if="row.warehouseOutbound.length">
                    <template v-for="(item,i) in row['warehouseOutbound']">
                    <span v-text="item.stock.company.address"></span>
                      <el-divider 
                        v-if="i == row['warehouseOutbound'].length - 1 ? false : true"
                      ></el-divider>
                    </template>
                  </template>
                </template> -->
                            </el-table-column>
                            <el-table-column label="备&ensp;&ensp;注" width="" align='center' prop="">
                            </el-table-column>
                            <el-table-column label="操&ensp;&ensp;作" width="" align='center'>
                                <template slot-scope="scope">
                                    <el-button @click.native.prevent="deleteRow1(scope.$index, editList)" type="text"
                                        size="small">
                                        删除
                                    </el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-form>
                    <div style="text-align: center">
                        <el-row style="margin: 20px 0">
                            <el-col>
                                <el-button type="primary" @click="submitall">确&ensp;&ensp;定</el-button>
                                <el-button type="primary" @click="cancellation">取&ensp;&ensp;消
                                </el-button>
                            </el-col>
                        </el-row>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="/css/exam/js/vue.js"></script>
    <script src="/css/elementui/index.js"></script>
    <script src="/css/exam/js/axios.min.js"></script>
    <script src="/css/exam/js/throttle.js"></script>
    <script>
    const app = new Vue({
        el: '#app',
        data() {
            return {
                loading: false,
                id: '',
                dialogVisible: false,
                get_warehouse_type: [], //出库类型
                // outbound_type:'',
                token: '',
                formInline: {
                    outbound_type: '',
                    incident: '',
                    applicant: ''
                },
                checkedList: [],
                deposit: [],

                formData: {
                    checkList: [],
                },
                editList: [],
                goodsdata: [], //分类名称
                materialList: [],
                checkcategory: [], //所属单位
                companys: [], //单位名称
                equipment_tools: {
                    classification_name: '',
                    materials: '',
                    unit: '',
                    classify: ''
                },
                options: [{
                    value: '1',
                    label: '领用出库'
                }, {
                    value: '3',
                    label: '报废出库'
                }],
                // formData:{
                //   sum:''
                // },
                // 信息列表
                information: [],
                etail_id: '', //明细id
                flag: '',
                rules: {
                    outbound_type: [{
                        required: true,
                        message: '请输入出库类型',
                        trigger: 'change'
                    }],
                    incident: [{
                            required: true,
                            message: '请输入出库事由',
                            trigger: 'blur'
                        },
                        {
                            min: 2,
                            max: 60,
                            message: '长度在 2 到 60 个字符',
                            trigger: 'blur'
                        }
                    ],
                    applicant: [{
                            required: true,
                            message: '请输入申请人',
                            trigger: 'blur'
                        },
                        {
                            min: 2,
                            max: 60,
                            message: '长度在 2 到 60 个字符',
                            trigger: 'blur'
                        }
                    ],
                },
                rules1: {
                    number: [{
                        required: true,
                        message: '请输入出库数量',
                        trigger: 'blur'
                    }],
                }

            }
        },
        created() {
            this.getUrlKey()
            this.getEditTableList()
            this.token = '{{ csrf_token() }}'
            console.log('this.token', this.token);
            this.classification()

            // console.log('this.id',this.id);
            this.affiliated_unit()
            // this.unit_name()
            this.data_echo()

            console.log(this.options[0].value, '22222222');
            console.log(this.options, '88888');

            this.wuzifenlei()



        },

        methods: {
            //这是添加的
            changereqair(val, item, index) {
                console.log(val, 'val');
                console.log(item, 'item');
                console.log('va11111111l', this.val);
                console.log('item222222', this.item);
                item.number = val * 1
                console.log(index, 'index');

                if (val * 1 > item.warehouse * 1) {
                    console.log('大于');

                    // 提示语句
                    this.$message({
                        message: '出库数量不能大于库存数',
                        type: 'error'
                    });

                    // this.$nextTick(()=>{
                    //   this.formData.checkList[index].number = item.warehouse
                    // })

                }

                if (val == 0) {
                    console.log('123');
                    this.$message({
                        message: '出库数量不能等于0',
                        type: 'error'
                    });
                    // this.$nextTick(()=>{
                    //   this.formData.checkList[index].number = 1
                    // })

                }

            },
            //这是修改的
            changereqair1(val, item, index) {
                item.number = val * 1
                this.val1 = val
                console.log('val11111', this.val1);
                if (item.stock && "warehouse" in item.stock) {
                    // console.log(this.item1,'this.item1')
                    // console.log(item.warehouse,'item.warehouse')

                    item.warehouse = item.stock.warehouse

                }
                if (val * 1 > item.warehouse + val) {
                    console.log('大于')
                    //提示语句
                    this.$message({
                        message: '出库数量不能大于库存数',
                        type: 'error'
                    });
                    console.log(this.editList, 'this.editList[index].number');
                    // this.$nextTick(()=>{
                    //   this.editList[index].number = item.warehouse
                    // })
                }
                if (val == 0) {
                    console.log('123')
                    this.$message({
                        message: '出库数量不能等于0',
                        type: 'error'
                    })
                    // this.$nextTick(()=>{
                    //   this.editList[index].number = 1
                    // })
                }
            },
            data_echo() {
                console.log('this.id1111', this.id);
                if (this.id) {
                    // this.getEditTableList(id)
                    //回显出库事由
                    let cause = localStorage.getItem("cause")
                    this.formInline.incident = cause
                    //回显申请人
                    let applicant = localStorage.getItem("applicant")
                    this.formInline.applicant = applicant
                    //回显出库类型
                    //  let outbound_type = localStorage.getItem("outbound_type")
                    //  this.formInline.outbound_type  = outbound_type
                    console.log('outbound_type', this.formInline.outbound_type);
                }
            },
            //获取当前浏览器地址url中的id
            getUrlKey() {
                var url = window.location.href; //获取当前url
                var dz_url = url.split('#')[0]; //获取#/之前的字符串
                //获取?之后的参数字符串
                if (dz_url.split('?')[1] != undefined) {
                    var cs = dz_url.split('?')[1];
                    var cs_arr = cs.split('&'); //参数字符串分割为数组
                    var cs = {};
                    for (var i = 0; i < cs_arr.length; i++) { //遍历数组，拿到json对象
                        cs[cs_arr[i].split('=')[0]] = cs_arr[i].split('=')[1]
                    }
                    this.id = cs.id

                    this.flag = 1


                } else {
                    this.i = ''
                    this.flag = 0
                };

            },
            //取消返  回列表页
            cancellation() {

                window.location.href = "/admin/warehouse/outbound"

            },
            selectEnable(row, rowIndex) {
                //  console.log('row',row);   
                if (row.warehouse !== 0) {
                    return true
                }


            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
                this.primary()
            },
            //获取物资分类
            async classification() {
                // let res = await axios.post('/admin/goods/goods_all')
                // console.log('res', res);
                // this.goodsdata = res.data.data

            },

            async wuzifenlei(){
            let res = await axios.post('/admin/goods/goodslistdata')
            this.goodsdata = res.data.data.list
            console.log('res11111111111', this.goodsdata);


            },

            //获取物资名称
            // async ChangeGoods(val) {
            //     let res = await axios.post('/admin/materialList/material_all', {
            //         goods_id: val
            //     })
            //     this.materialList = res.data.data
            //     this.equipment_tools.materials = ''

            // },


            //获取所有所属单位适用于下拉列表
            async affiliated_unit() {
                let res = await axios.post('/admin/stock/checkcategory_all')
                this.checkcategory = res.data.data

            },
            //获取所有单位名称适用于下拉列表
            async ChangeHandler(val) {
                let res = await axios.post('/admin/stock/company_all', {
                    checkcategory_id: val
                })
                this.companys = res.data.data
                this.equipment_tools.classify = ''

            },
            // //获取所有单位名称适用于下拉列表
            //   async unit_name(){
            //   let res = await axios.post('/admin/stock/company_all')
            //   this.companys = res.data.data
            //   },
            //回显
            async getEditTableList() {
                let res = await axios.post('/admin/warehouseOutbound/referweb', {
                    id: this.id
                })
                console.log('res', res);
                console.log('edit', this.editList);
                this.editList = res.data.data.warehouseOutbound || []

                this.editList.forEach(item => {
                    console.log('item', item);
                    if (item.outbound_type == 1) {
                        this.formInline.outbound_type = this.options[0].value
                    }
                    if (item.outbound_type == 2) {
                        this.formInline.outbound_type = this.options[1].value
                    }
                    if (item.outbound_type == 3) {
                        this.formInline.outbound_type = this.options[2].value
                    }
                })

                // console.log(res.data.data.get_outbound_type,'this.editList');
                // this.get_warehouse_type = res.data.data.get_outbound_type 
                console.log('this.get_warehouse_type', this.get_warehouse_type)

                //改为label 和 value 格式的
                // this.options = Object.keys( this.get_warehouse_type).map(item => {
                //   return {
                //     value:item,
                //     label: this.get_warehouse_type[item]
                //   }
                // })
                // console.log('options',this.options);
            },
            //打开弹窗
            async add_details() {
                try {
                    await this.$refs.increase.validate()
                    this.dialogVisible = true

                    this.primary()


                } catch (error) {
                    console.log(error);
                }
            },
            //获取物资列表
            async primary() {
                 var a = this.equipment_tools.classification_name.toString()

            let array = a.split(',')

            let last = array[array.length-1]

            console.log(last,'last');

                try {
                    //  await this.$refs.verification.validate()   
                    let param = {
                        goods_id: last,
                        name: this.equipment_tools.materials,
                        checkcategory_id: this.equipment_tools.unit,
                        company_id: this.equipment_tools.classify
                    }
                    let res = await axios.post('/admin/stock/stocklistdatatoadd', param)
                    let data = res.data.data.stock
                    console.log(data, 'data11111111111111111');
                    this.information = data
                } catch (error) {
                    console.log('请求失败：' + error);
                }
            },
            //添加明细
            async btnok() {
                let checked = []
                console.log('this.editList111', this.editList);
                this.checkedList.forEach(item => {
                    item.warehouse_materials_id = item.id,
                        item.isAdd = true
                })
                console.log('this.formData.checkList', this.formData.checkList);
                //添加的  这部分的
                let isExist = false

                console.log('checkList', this.formData.checkList)
                console.log('deposit', this.deposit)
                // this.deposit.forEach(item => {
                //   if (this.formData.checkList.some(checkItem => checkItem.company.comName === item.company.comName && checkItem.material_list.name === item.material_list.name)) {
                //     isExist = true
                //   }
                // })
                // if (!isExist) {
                //   this.formData.checkList = this.formData.checkList.concat(this.deposit)
                // }
                if (!this.id) {
                    if (this.formData.checkList.length > 0) {
                        let toAdd1 = this.deposit.filter(checkItem => !this.formData.checkList.some(item =>
                            item.company.comName === checkItem.company.comName && item.material_list
                            .name === checkItem.material_list.name))
                        if (toAdd1.length > 0) {
                            this.formData.checkList = [...this.formData.checkList, ...toAdd1]
                        }
                    } else {
                        console.log('2');
                        this.formData.checkList = this.formData.checkList.concat(this.deposit)
                    }
                }

                //修改的 
                if (this.id) {
                    //  let isfolat = false
                    if (this.editList) {
                        this.checkedList.forEach(item => {
                            var stock = {
                                company: item.company,
                                material_list: item.material_list,
                                goods: item.goods,
                                checkcategory: item.checkcategory,
                                norms: item.norms,
                                warehouse: item.warehouse
                            }
                            item.stock = stock
                        })
                        // this.editList = this.editList.concat(this.checkedList)
                        console.log('editList', this.editList)
                        console.log('checkedList1111111111', this.checkedList);
                        let toAdd = this.checkedList.filter(checkItem => !this.editList.some(item => item
                            .stock.company.comName === checkItem.stock.company.comName && item.stock
                            .material_list.name === checkItem.stock.material_list.name))

                        if (toAdd.length > 0) {
                            console.log('toAdd', toAdd);
                            this.editList = [...this.editList, ...toAdd]
                        }
                    } else {
                        console.log('2');
                        this.editList = this.editList.concat(this.checkedList)
                    }
                }
                //  this.editList = this.editList.concat(this.checkedList)
                this.dialogVisible = false
                console.log('checkList', this.formData.checkList);
                console.log('editList', this.editList);
                if (this.id) {
                    this.formData.checkList.forEach(item => {
                        // console.log(item,'item2222222222');
                        let stock = {}
                        item['stock'] = item
                    })
                }
            },
            //勾选列表
            handleSelectionChange(val) {
                this.checkedList = val //修改
                console.log('this.checkedList', this.checkedList);
                this.deposit = val //添加
                console.log('deposit', this.deposit);
            },
            //关闭弹窗
            btnCancel() {
                this.dialogVisible = false
            },
            //添加
            submit: throttle(async function(event) {

                if (this.formData.checkList.some(item => (item.number > item.warehouse) || item
                        .number == 0)) {

                    return
                }

                await this.$refs.increase.validate()
                await this.$refs.formData.validate()
                let outbound = []
                this.formData.checkList.forEach(element => {
                    outbound.push({
                        stock_id: element.id,
                        number: element.number
                    })

                })
                let param = {
                    cause: this.formInline.incident,
                    applicant: this.formInline.applicant,
                    type: this.formInline.outbound_type,
                    outbound: outbound

                }
                axios.post('/admin/warehouseOutbound/refer', param).then(res => {
                    console.log(res, 306);
                    if (res.data.code == 200) {
                        this.$message({
                            message: '保存成功',
                            type: 'success'
                        });
                        this.formData.checkList = []
                        window.location.href = "/admin/warehouse/outbound"
                    } else {
                        this.$message(res.data.message)
                    }
                })
            }, 1000),
            //修改
            submitall: throttle(async function(event) {
                this.loading = true
                //修改判断库存
                this.editList.forEach(ele => {
                    if (ele.stock) {
                        ele.warehouse = ele.stock.warehouse
                    }
                    console.log(ele);
                })
                if (this.editList.some(item => (item.number > item.warehouse + item.number) || item
                        .number == 0)) {
                    this.$message({
                        message: '数量不能大于库存量或者等于0',
                        type: 'error'
                    });
                    this.loading = false
                    return

                }
                await this.$refs.increase.validate()

                let outbound = []
                // this.editList.forEach(element => {
                //   console.log('element',element);
                //  outbound.push({
                //  stock_id:element.stock_id,
                //  number:element.number
                //   })
                // })
                this.editList.forEach(element => {
                    if (element.isAdd) {
                        outbound.push({
                            stock_id: element.id,
                            number: element.number,
                        })
                    } else {
                        outbound.push({
                            stock_id: element.stock_id,
                            number: element.number,
                        })
                    }
                })
                let param = {
                    id: this.id,
                    cause: this.formInline.incident,
                    applicant: this.formInline.applicant,
                    type: this.formInline.outbound_type,
                    outbound: outbound,
                    _token: this.token
                }
                axios.post('/admin/warehouseOutbound/refer', param).then(res => {
                    console.log(res, 306);
                    if (res.data.code == 200) {
                        this.$message({
                            message: '保存成功',
                            type: 'success'
                        });
                        this.formData.checkList = []
                        window.location.href = "/admin/warehouse/outbound"
                    } else {
                        this.loading = false
                        this.$message({
                            message: '数量不能大于库存量或者等于0',
                            type: 'error'
                        })

                    }
                    this.loading = false
                })
            }, 100),
            //删除行
            deleteRow(index, rows) {
                console.log('rows', rows);
                rows.splice(index, 1);
                // console.log('#',this.allarr)
                // console.log('index',index);
                // console.log(rows);
            },
            //删除行
            deleteRow1(index, rows) {
                console.log('rows', rows);
                rows.splice(index, 1);
                console.log('#', this.editList)

            },
        },

    })
    </script>
    <style scoped>
    .el-table .el-table__cell:first-child {
        text-align: center;
    }

    .el-divider {
        margin: 0;
    }
    </style>
</body>

</html>